package com.sc.controller;



import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sc.model.Product;
import com.sc.model.User;
import com.sc.service.ProductService;

@Controller
@RequestMapping("/home")
public class ProductController {

	@Autowired
	private ProductService productService;
	
	@RequestMapping 
	public String getAllProduct(Model model,HttpServletRequest req){
		
		List<Product> allProduct=productService.getAllProduct();
		List<Product> products=productService.getProducts();
		model.addAttribute("products", products);
		model.addAttribute("allProduct", allProduct);
		User user =(User)req.getSession().getAttribute("user");
		model.addAttribute("user", user);
		return "product/home";
	}
}
